home *** CD-ROM | disk | FTP | other *** search
-
-
- ‹
-
- ‹
-
- åHow Does Menu Events Work?
-
-
-
- When you send a Query Menu List event, the ideal application dispatches
-
- the resulting high-level event as an Apple event without looking at it. The
-
- event handler provided by Menu Events forms a reply to the query on the
-
- basis of the applicationΓÇÖs menu list structure. Through all of this, the
-
- application stays in the background or in the foreground, wherever it was
-
- before.
-
-
-
- When you send a Query Menu or Select Menu Item event, the same things
-
- happen, but the event handling is more complex.
-
-
- First, it verifies that the given menu is valid. If not, it returns
-
- noSuchMenuErr.
-
-
- Second, it asks for the application to be brought to the front for user
-
- interaction, because it could be dangerous to feed the target application a
-
- menu bar click while it is in the background, something that never happens
-
- in normal operation. If it is refused, it returns errAENoUserInteraction.
-
-
- Third, it patches some traps so that it can gain control of menu bar clicks.
-
- If it finds that the patches are already in place, meaning that an earlier
-
- Menu event is still pending, it returns menuEventPendingErr.
-
-
- Fourth, if everything is OK, it posts an event to simulate a mouse click in
-
- the menu bar, with modifier keys if specified. The patched traps tell the
-
- application that no menu item was selected. The patches then remove
-
- themselves. This step is solely to ensure that the application brings its
-
- menus up to date.
-
-
- Fifth (in the case of a Select Menu Item event), it verifies that the given
-
- menu item is valid and enabled. If not, it returns noSuchMenuErr,
-
- noSuchMenuItemErr, or menuItemDisabledErr. If the menu has a
-
- non-standard menu definition procedure, its way of counting or disabling
-
- items may differ from the norm. Menu Events assumes that the count and
-
- enable/disable flags are set in the normal fashion.
-
-
- Sixth (in the case of a Select Menu Item event), it posts an event to
-
- simulate another mouse click in the menu bar, with modifier keys if
-
- specified. The patched traps tell the application that the given item was
-
- selected. The patches then remove themselves. From there, it is exactly
-
- as though the user had actually made the selection.
-
-
- NOTE: When replying to any of the three event types, Menu Events
-
- includes a null ΓÇ£tattooΓÇ¥ parameter to prove that it handled the event,
-
- rather than some handler supplied by the application. Many Microsoft
-
- applications, for example, bind their own handler over all Apple event
-
- classes, preventing Menu Events from working. (The handler wouldnΓÇÖt be
-
- a problem if it returned errAEEventNotHandled when faced with an
-
- unknown Apple event, as it should.)
-
-
-
-
- xUser Interaction Policy
-
-
- The Apple Event Manager implements a complicated but sensible model for
-
- joint sender/receiver control over user interaction. Menu Events doesnΓÇÖt
-
- know which menu selections will really require user interaction, but even
-
- if it did, it would still have to request user interaction just to bring the
-
- target application to the front, where an application always expects to be
-
- when it sees a mouse-down event.
-
-
-
- The sending program must set the kAECanInteract or kAEAlwaysInteract
-
- flag in the sendMode parameter to AESend, in order to achieve user
-
- interaction. It should also set the kAECanSwitchLayer flag, allowing the
-
- target application to come to the front without having to post a
-
- notification request. If the target application is in the background, and
-
- receives a Menu event with this flag not set, it may go into a notification
-
- wait state, disrupting its usual background event processing behavior.
-
-
- If both the sending program and target application are in the background,
-
- the kAECanSwitchLayer flag has no effect, and the notification request is
-
- posted anyway. Since your sending program is indirectly instigating a
-
- user interaction, it should call AEInteractWithUser before sending the
-
- Menu event, if there is any chance that it will be in the background at the
-
- time. Another approach would be to call SetFrontProcess to activate the
-
- target application before sending it a Menu event.
-
-
- If the target application is in that rare user interaction state,
-
- kAEInteractWithSelf, where it disallows interaction requested by any
-
- other process, the Menu event handler will respect that state, and refuse
-
- the event.
-
-
- If the sending and receiving applications are on different machines, the
-
- usual program linking checks apply, namely, Sharing Setup (on/off),
-
- Users & Groups (permission to user), and FinderΓÇÖs Sharing (permission to
-
- application).
-
-
- If the Menu Events extension is locked, using FinderΓÇÖs Get Info dialog, then
-
- only target applications which explicitly allow interaction with all
-
- processes can be controlled by remote senders. If it is not locked, and if
-
- it sees that the user interaction state is kAEInteractWithLocal, which is
-
- the default value, it will momentarily change it to kAEInteractWithAll, so
-
- that events sent from a remote machine are not rejected. This trick is
-
- necessary for Menu Events to be useful with most target applications,
-
- because most will assume the default interaction state, not expecting any
-
- remote sender to require user interaction. The icon displayed by Menu
-
- Events at startup shows whether or not the lock is in effect.
-
-
- IMPORTANT NOTE: Users of machines where Menu Events is installed
-
- should be careful about which users and applications are enabled for
-
- remote program linking. In particular, guest users should not be allowed
-
- to do program linking unless Menu Events is locked.
-
-
-
-
- xApple Event Recording Capability
-
-
- When you are using a high-level-event-aware application on a machine
-
- where Menu Events is installed, menu item selection behavior is modified
-
- if the Caps Lock key is down at the time you release the mouse button.
-
- Menu Events will create a Select Menu Item Apple event to represent the
-
- selection (including parameters for any modifier keys which were
-
- pressed), so that a script editor can record the event as a script
-
- command. A gentle ΓÇ£twangΓÇ¥ sound confirms that this has happened.
-
- Whether or not it succeeds in recording the event, the menu selection will
-
- be processed in the usual way.
-
-
-
- If the application is scriptable in its own right, a script editor may record
-
- two commands when you select an item from its menus. To prevent this
-
- duplication, you can use the itemΓÇÖs Command-key equivalent (if any), or
-
- release the Caps Lock key, to suppress the recording capability.
-
-
- If an application seems to be misinterpreting or not receiving menu
-
- selections, try again with the Caps Lock key up. The command will not be
-
- recorded, but should work as usual.
-
-
- NOTE: While receiving a Select Menu Item event does simulate a menu
-
- selection, it does not cause a Select Menu Item script command to be
-
- recorded.
-
-
-
-